from server import db
from sqlalchemy import Column, String, DateTime, func
from server.model.sys.role_route import RoleRoute
from server.model import BaseOrm


# 角色
class Role(BaseOrm):
    __tablename__ = 'role'
    name = Column(String(255), comment="角色名称")
    description = Column(String(255), comment="描述")
    create_time = Column(DateTime, nullable=False, server_default=func.now(), comment="创建时间")
    update_time = Column(DateTime, onupdate=func.now(), comment="修改时间 ")

    def get_role_routes(self):
        role_routes = RoleRoute.query.filter(RoleRoute.role_id == self.id).all()
        return role_routes


db.create_all()
